<template>
  <div class="content_a">
    <div class="content" v-if="index==0">
      <div class="containt-box">
        <div class="success_step">
          <p class="step">
            <span>付款成功（募集中）</span>
          </p>
          <p class="time">{{buy_list.dealTime}}</p>
        </div>
        <div class="success_step">
          <p class="step">投标成功</p>
          <p class="time">预计1个工作日内</p>
        </div>
      </div>
      <div v-if="adlist.length!==0">
        <a href="javascript:void(0)" class="success_banner" v-bind:key="item.url" v-for="item in adlist" @click="jump(item.link)">
          <img v-lazy="item.url" />
        </a>
      </div>
    </div>

    <div class="content_s" v-if="index==1">
      <div class="success_step">
        <p class="step">
          <span>付款成功（募集中）</span>
        </p>
        <p class="time">{{buy_list.dealTime}}</p>
      </div>

      <div class="nav">
        您有{{cont}}次翻牌福利
      </div>
      <div class="des">
        最高950元抵价券等您拿
      </div>
      <div class="card_content">
        <div class="item" v-for="(item,index) in cardlist" @click="selset(index)" :class="{'active':item.select}">
          <img src="../../public/imgs/buysuccess/card_default.png" alt="">
          <div class="item_sss">
            <div class="s_1">
              <span>￥</span>{{parseInt(item.money)}}
            </div>
            <div class="s_2">满{{parseInt(item.quota)}}元<br/> 可用</div>
            <div class="s_3">抵价券</div>
          </div>
        </div>
      </div>

      <mt-popup v-model="popupVisible" popup-transition="popup-slide">
      </mt-popup>
      <div class="pouple animated" :class="{'zoomIn':popupVisible}" v-show="popupVisible">
        <div class="title">
          恭喜您获得首投抵价券
        </div>
        <div class="s_des">以上抵价券15天内有效，请及时使用</div>
        <div class="content">
          <div class="item_sss" v-for="item in selsetcrad">
            <div class="s_1">
              <span>￥</span>{{parseInt(item.money)}}
            </div>
            <div class="s_2">满{{parseInt(item.quota)}}元<br/> 可用</div>
            <div class="s_3">抵价券</div>
          </div>

        </div>
        <div class="btn" @click="jumpCom()">
          立即查收
        </div>
        <div class="close" @click="popupVisible=false">
          <img src="../../public/imgs/icon-close.png" alt="">
        </div>
      </div>
    </div>

  </div>

</template>

<script>
import { Popup } from "mint-ui";
export default {
  props: [],
  data() {
    return {
      index: 0,
      money: "",
      starttime: "",
      endtime: "",
      adlist: [],
      buy_list: {},
      sessionid: "",
      buy_list: {},
      cardlist: [
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false },
        { money: "0", select: false }
      ],
      number: 0,
      cont: 0,
      lock: true,
      popupVisible: false,
      selsetcrad: []
    };
  },
  methods: {
    getstatus(id,sessionid) {
      this.$http
        .get(this.Interface.gettopic_pay_success_is_exhibition, {
          params: { sessionid: sessionid, orderNo: id }
        })
        .then(res => {
          if (res.data.success) {
            if (res.data.data.isExhibition) {
             this.index=1;
             this.init()
            } else {
             this.index=0
            }
          }
        });
    },

    jumpCom() {
      this.Uitis.JumpNavite("jumpToCoupon", "1");
    },
    init() {
      this.$http
        .get(this.Interface.getTopicPaySuccessFlopWeb, {
          params: { sessionid: this.sessionid }
        })
        .then(res => {
          if (res.data.success && res.data.data.list !== null) {
            for (var i = 0; i < res.data.data.list.length; i++) {
              res.data.data.list[i].select = false;
            }
            this.cardlist = res.data.data.list;
            this.cont = res.data.data.rewardSize;
          }
        });
    },
    selset(index) {
      if (this.cont > 0) {
        if (this.cardlist[index].select == true) {
          return false;
        }
        if (this.lock) {
          this.lock = false;
          this.$http
            .get(this.Interface.gettopic_pay_Success_flop_receive, {
              params: { sessionid: this.sessionid }
            })
            .then(res => {
              if (res.data.success) {
                if (res.data.data.money == this.cardlist[index].money) {
                  this.cardlist[index].money = res.data.data.money;
                  this.cardlist[index].quota = res.data.data.quota;
                  this.cardlist[index].select = true;
                  var oc = {};
                  oc.money = res.data.data.money;
                  oc.quota = res.data.data.quota;
                  this.selsetcrad.push(oc);
                } else {
                  for (let i = 0; i < this.cardlist.length; i++) {
                    if (this.cardlist[i].money == res.data.data.money) {
                      var arr = this.cardlist[index];
                      this.cardlist[index] = this.cardlist[i];
                      this.cardlist[i] = arr;
                    }
                  }
                  this.cardlist[index].money = res.data.data.money;
                  this.cardlist[index].quota = res.data.data.quota;
                  this.cardlist[index].select = true;
                  var oc = {};
                  oc.money = res.data.data.money;
                  oc.quota = res.data.data.quota;
                  this.selsetcrad.push(oc);
                }
                this.cont--;
                this.lock = true;
                if (this.cont <= 0) {
                  this.lock = false;
                  setTimeout(() => {
                    for (var i = 0; i < this.cardlist.length; i++) {
                      this.cardlist[i].select = true;
                    }
                  }, 1000);
                  setTimeout(() => {
                    this.popupVisible = true;
                  }, 2000);
                }
              }
            });
        }
      }
    },
    jump(url) {
      var typeStyle = "jumpToEvents";
      var data = {
        result: 0,
        type: typeStyle,
        urlEvents: url,
        share: {}
      };
      if (
        this.Uitis.ua.indexOf("mzapp") !== -1 &&
        (this.Uitis.ua.indexOf("iphone") !== -1 ||
          this.Uitis.ua.indexOf("ipad") !== -1)
      ) {
        this.Uitis.setupWebViewJavascriptBridge(function(bridge) {
          bridge.callHandler("ObjcCallBackJs", JSON.stringify(data), function(
            response
          ) {});
        });
      } else if (
        this.Uitis.ua.indexOf("mzapp") !== -1 &&
        this.Uitis.ua.indexOf("android") !== -1
      ) {
        window.demo.jumpToEvents(JSON.stringify(data));
      }
    }
  },

  created() {
  
    this.Uitis.getInfo().then(res => {
        this.sessionid = res.sessionid;
       this.getstatus(APP.GetLocationParams("partId"),res.sessionid);
      this.$http
        .get(this.Interface.getMyinvestDetail, {
          params: {
            partId: APP.GetLocationParams("partId"),
            sessionid: res.sessionid
          }
        })
        .then(res => {
          if (res.data.success == true) {
            this.buy_list = res.data.data;
          }
        });

    });

    //广告列表
    this.$http
      .get(this.Interface.getAdList, { params: { adspaceId: 20 } })
      .then(res => {
        if (res.data.success == true) {
          this.adlist = res.data.data.list;
        }
      });
  }
};
</script>


<style lang="less">
#type_1,#type_1{
  display: none;
}
.content_s {
  .s_des {
    font-size: 26px;
    text-align: center;
    color: #666;
    padding: 30px 0px 0px 0px;
  }
  .des {
    font-size: 28px;
    color: #ff6b5c;
    padding-left: 70px;
    padding-bottom: 40px;
  }
  .success_step {
    padding-left: 60px;
    background: url("../../public/imgs/buysuccess/busuccess_one.png") left top
      no-repeat;
    background-size: 57px 57px;
    height: 57px;
    margin-left: 40px;
    margin-top: 70px;
    margin-bottom: 70px;
  }
  .success_step p {
    margin-left: 20px;
  }
  .success_step .time {
    padding-top: 20px;
    font-size: 20px;
    color: #999;
    text-align: left;
  }
  .success_step .step {
    font-size: 32px;
    color: #333333 !important;
    text-align: left;
    line-height: 32px;
    font-family: "苹方";
  }
  .close {
    position: absolute;
    left: 50%;
    margin-left: -34px;
    bottom: -150px;
    img {
      width: 68px;
    }
  }
  .pouple {
    width: 600px;
    left: 75px;
    position: fixed;
    top: 50%;
    margin-top: -450px !important;
    z-index: 20001;
    background: #fff;
    border-radius: 10px;
    box-sizing: border-box;
    padding: 60px 70px;
    text-align: center;
    .title {
      font-size: 40px;
      color: #333;
      font-weight: bold;
    }
    .btn {
      width: 440px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #ff405e;
      color: #fff;
      font-size: 40px;
      font-weight: bold;
      border-radius: 10px;
      line-height: inherit;
      height: 80px;
    }
    .content {
      padding: 45px 0px 65px 0px;
      display: flex;
      justify-content: center;
      align-items: center;
      .item_sss {
        background: url(../../public/imgs/buysuccess/card_alert.png) no-repeat;
        background-size: contain;
        height: 300px;
        width: 200px;
        box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
        border-radius: 10px;
        .s_1 {
          color: #ff6b5c;
          font-size: 48px;
          margin-top: 50px;
          font-family: "DinPro";
          span {
            font-size: 34px;
          }
        }
        .s_2 {
          font-size: 28px;
          color: #ff6b5c;
          margin-top: 30px;
          font-family: "DinPro";
        }
        .s_3 {
          font-size: 18px;
          color: #ff6b5c;
          margin-top: 30px;
        }
      }
      .item_sss:first-child {
        margin-right: 30px;
      }
    }
  }

  .nav {
    margin: 0 auto;
    width: 671px;
    height: 80px;
    background: url(../../public/imgs/buysuccess/choujiang_nav.png) no-repeat;
    background-size: contain;
    margin-top: 40px;
    font-size: 34px;
    color: #fff;
    font-weight: bold;
    display: flex;
    align-items: center;
    padding-left: 50px;
    box-sizing: border-box;
    margin-bottom: 30px;
  }
  .card_content {
    display: flex;
    width: 670px;
    box-sizing: border-box;
    margin: 0 auto;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    text-align: center;
    .item {
      width: 200px;
      height: 300px;
      background-size: contain;
      border-radius: 10px;
      position: relative;
      margin-bottom: 25px;
      position: relative;
      transition: 1s;
      transform-style: preserve-3d;
      img {
        border-radius: 10px;
        position: absolute;
        top: 0px;
        left: 0px;
        width: 200px;
        height: 300px;
        box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
        backface-visibility: hidden;
      }
      .item_sss {
        background: url(../../public/imgs/buysuccess/card_alert.png) no-repeat;
        background-size: contain;
        border-radius: 10px;
        top: 0px;
        left: 0px;
        width: 200px;
        height: 300px;
        box-shadow: 8.192px 5.736px 20px 0px rgba(0, 0, 0, 0.2);
        transform: rotateY(180deg);
        backface-visibility: hidden;
        position: absolute;
        -webkit-backface-visibility: hidden;
      }
    }
    .s_1 {
      color: #ff6b5c;
      font-size: 48px;
      margin-top: 50px;
      font-family: "DinPro";
      span {
        font-size: 34px;
      }
    }
    .s_2 {
      font-size: 28px;
      color: #ff6b5c;
      margin-top: 30px;
      font-family: "DinPro";
    }
    .s_3 {
      font-size: 18px;
      color: #ff6b5c;
      margin-top: 30px;
    }
  }
  .active {
    transform: rotateY(180deg);
  }
  .rules {
    width: 670px;
    margin: 0 auto;
    margin-top: 36px;
    padding-bottom: 30px;
    .title {
      font-size: 30px;
      font-weight: bold;
      font-family: "苹方";
      color: #333;
      margin-bottom: 25px;
    }
    .des {
      font-size: 26px;
      color: #666;
      line-height: 40px;
    }
    .small {
      font-size: 22px;
      color: #666;
      line-height: 40px;
      margin-top: 20px;
    }
  }
}
.content_a{
.content {
  height: 100%;
  background: #fff;
}
.containt-box {
  padding: 50px 0 50px 30px;
  margin-bottom: 34px;
  background-color: #fff;
}

.containt-box .success_step {
  padding-left: 60px;
  background: url("../../public/imgs/busuccess_one2.0.png") left top no-repeat;
  background-size: 57px 116px;
  height: 116px;
}
.success_step p {
  margin-left: 20px;
}
.containt-box .success_step .step {
  font-size: 32px;
  color: #333333 !important;
  text-align: left;
  line-height: 32px;
  font-family: "苹方";
}

.containt-box .success_step .time {
  padding-top: 20px;
  font-size: 20px;
  color: #999;
  text-align: left;
}

.containt-box .success_step:nth-child(2) {
  background: url("../../public/imgs/busuccess_two2.0.png") left top no-repeat;
  background-size: 57px 116px;
  height: auto;
}

.containt-box .success_step:nth-child(2) .step {
  padding-top: 46px;
  color: #999999;
}

.success_banner {
  display: block;
  width: 100%;
  padding: 0px 30px;
  box-sizing: border-box;
}

.success_banner img {
  width: 100%;
}
}
</style>
